const renderNav = require("../../lib/bottom_nav");
require("../../assets/css/index.less")
require("./mine.less");

const request = require("../../lib/requst")

function $(select){
    return document.querySelector(select)
}

window.onload = ()=>{
    //渲染打卡信息
    request.get("/api/user/clockInInfo").then(res=>{
        if(res.data.errno === 0){
            $(".day").textContent = res.data.data.clockCount;
            if(res.data.data.isClockIn){
                $(".sign").textContent = "已打卡";
                $(".sign").className = "sign_wanc"
            }else{
                $(".sign").textContent = "今日打卡";
                $(".sign").className = "sign"
            }
        }
    })
    // 渲染运动时间 和 消耗卡路里
    request.get("/api/exercise").then(res => {
        if(res.data.errno ===0 ){
            console.log(res.data);
            $(".times").textContent = res.data.data.sum7Duration;
            $(".cas").textContent = res.data.data.sum7Calorie;
        }
    })
    // 渲染头像
    let API = "http://fitness.h5.itsource.cn:3701"
    request.get("/api/user/info").then(res => {
        if(res.data.errno === 0 ){
            $(".img").src = API + res.data.data.imgUrl;
        }
    })
    renderNav("mine");
}